/*
  流程控制（flow-control）
  - @if/@else
  - @each 
  - @for 
  - @while
*/

@use 'sass:math';

$light-background: #f2ece4;
$light-text: #036;
$dark-background: #6b717f;
$dark-text: #d2e1dd;


@mixin avatar($size, $circle) {
  width: $size;
  height: $size;

  // 为真才设置圆角
  @if $circle {
    border-radius: math.div($size, 2)
  }
}

@mixin theme-colors($light-theme: true) {
  @if $light-theme {
    background-color: $light-background;
    color: $light-text;
  } @else {
    background-color: $dark-background;
    color: $dark-text;
  }
}

@mixin triangle($size, $color, $direction) {
  height: 0;
  width: 0;

  border-color: transparent;
  border-style: solid;
  border-width: math.div($size, 2);

  @if $direction == up {
    border-bottom-color: $color;
  } @else if $direction == right {
    border-left-color: $color;
  } @else if $direction == down {
    border-top-color: $color;
  } @else if $direction == left {
    border-right-color: $color;
  } @else {
    @error "Unknown direction #{$direction}.";
  }
}

.square-av {
  @include avatar(100px, false)
}

.circle-av {
  @include avatar(100px, $circle: true)
}

.banner {
  @include theme-colors($light-theme: true);
  body.dark & {
    @include theme-colors($light-theme: false)
  }
}

.next {
  @include triangle(5px, black, right);
}